package com.deyuanyun.pic.risk.controller.vo;

import com.deyuanyun.pic.common.util.DateUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.risk.domain.HcaInfo;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.*;

/**
 * 高后果区列表返回对象
 *
 * @author huanglw
 * @date
 *
 * History: [修改人][时间][修改描述]
 */
public class HcaInfoVO {

    /**
     * 主键
     */
    private String id;

    /**
     * 管道ID
     */
    private String pipeLineName;

    /**
     * 统一编号
     */
    private String code;

    /**
     * 高后果区(自定义编号)
     */
    private String hcaNumber;

    /**
     * 起点位置描述
     */
    private String fromLocationDescription;

    /**
     * 终点位置描述
     */
    private String toLocationDescription;

    /**
     * 评价时间
     */
    private String riskDate;

    /**
     * 可能存在的威胁总分
     */
    private String threatScore;

    /**
     * 高后果区描述
     */
    private String hacGrade;

    /**
     * 高后果区描述
     */
    private String description;

    /**
     * 潜在影响半径（m）
     */
    private String influenceRadius;

    /**
     * 高后区长度(m)
     */
    private String hcaLength;

    /**
     * 起点绝对距离（m）
     */
    private String fromMileage;

    /**
     * 起点最近参考
     */
    private String fromReference;

    /**
     * 起点相对最近参考点距离
     */
    private String fromReferenceDistance;

    /**
     * 终点绝对距离（m）
     */
    private String toMileage;

    /**
     * 终点最近参考
     */
    private String toReference;

    /**
     * 终点相对最近参考点距离
     */
    private String toReferenceDistance;

    /**
     * 记录人
     */
    private String recrder;

    /**
     * 记录时间
     */
    private String recordTime;

    /**
     * 创建备注
     */
    private String remark;

    /**
     * 链接GIS结果表
     */
    private String gisId;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getHcaNumber() {
        return hcaNumber;
    }

    public void setHcaNumber(String hcaNumber) {
        this.hcaNumber = hcaNumber;
    }

    public String getFromLocationDescription() {
        return fromLocationDescription;
    }

    public void setFromLocationDescription(String fromLocationDescription) {
        this.fromLocationDescription = fromLocationDescription;
    }

    public String getToLocationDescription() {
        return toLocationDescription;
    }

    public void setToLocationDescription(String toLocationDescription) {
        this.toLocationDescription = toLocationDescription;
    }

    public String getRiskDate() {
        return riskDate;
    }

    public void setRiskDate(String riskDate) {
        this.riskDate = riskDate;
    }

    public String getThreatScore() {
        return threatScore;
    }

    public void setThreatScore(String threatScore) {
        this.threatScore = threatScore;
    }

    public String getHacGrade() {
        return hacGrade;
    }

    public void setHacGrade(String hacGrade) {
        this.hacGrade = hacGrade;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getInfluenceRadius() {
        return influenceRadius;
    }

    public void setInfluenceRadius(String influenceRadius) {
        this.influenceRadius = influenceRadius;
    }

    public String getHcaLength() {
        return hcaLength;
    }

    public void setHcaLength(String hcaLength) {
        this.hcaLength = hcaLength;
    }

    public String getFromMileage() {
        return fromMileage;
    }

    public void setFromMileage(String fromMileage) {
        this.fromMileage = fromMileage;
    }

    public String getFromReference() {
        return fromReference;
    }

    public void setFromReference(String fromReference) {
        this.fromReference = fromReference;
    }

    public String getFromReferenceDistance() {
        return fromReferenceDistance;
    }

    public void setFromReferenceDistance(String fromReferenceDistance) {
        this.fromReferenceDistance = fromReferenceDistance;
    }

    public String getToMileage() {
        return toMileage;
    }

    public void setToMileage(String toMileage) {
        this.toMileage = toMileage;
    }

    public String getToReference() {
        return toReference;
    }

    public void setToReference(String toReference) {
        this.toReference = toReference;
    }

    public String getToReferenceDistance() {
        return toReferenceDistance;
    }

    public void setToReferenceDistance(String toReferenceDistance) {
        this.toReferenceDistance = toReferenceDistance;
    }

    public String getRecrder() {
        return recrder;
    }

    public void setRecrder(String recrder) {
        this.recrder = recrder;
    }

    public String getRecordTime() {
        return recordTime;
    }

    public void setRecordTime(String recordTime) {
        this.recordTime = recordTime;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void forDomain(HcaInfo domain) {

        // 主键
        this.id = domain.getId();
        // 统一编号
        this.code = domain.getCode();
        // 管道ID
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 高后果区编号
        this.hcaNumber = domain.getHcaNumber();
        // 高后区长度(m)
        this.hcaLength = NumberFormat.format(domain.getHcaLength(), NumberFormat.FMT_PLACES3);
        // 起点位置描述
        this.fromLocationDescription = domain.getFromLocationDescription();
        // 终点位置描述
        this.toLocationDescription = domain.getToLocationDescription();
        // 起点绝对距离（m）
        this.fromMileage = NumberFormat.format(domain.getFromMileage(), NumberFormat.FMT_PLACES3);
        // 起点最近参考
        this.fromReference = domain.getFromReference();
        // 起点相对最近参考点距离
        this.fromReferenceDistance = NumberFormat.format(domain.getFromReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 终点绝对距离（m）
        this.toMileage = NumberFormat.format(domain.getToMileage(), NumberFormat.FMT_PLACES3);
        // 终点最近参考
        this.toReference = domain.getToReference();
        // 终点相对最近参考点距离
        this.toReferenceDistance = NumberFormat.format(domain.getToReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 评价时间
        this.riskDate = StringUtils.convertDateToString(domain.getRiskDate(), StringUtils.DATE);
        // 可能存在的威胁总分
        this.threatScore = NumberFormat.format(domain.getThreatScore());
        // 高后果区描述
        this.description = domain.getDescription();
        // 高后果区等级
        this.hacGrade = CodeUtil.getName(domain.getHacGrade());
        // 潜在影响半径（m）
        this.influenceRadius = NumberFormat.format(domain.getInfluenceRadius(), NumberFormat.FMT_PLACES3);
        // 记录人
        this.recrder = domain.getRecrder();
        // 记录时间
        this.recordTime = DateFormat.format(domain.getRecordTime());
        // 创建备注
        this.remark = domain.getCreateRemark();

        // 链接GIS结果表
        this.gisId = domain.getGisId();
    }

    public Page<HcaInfoVO> forDomain(Page<HcaInfo> hcaInfoList) {
        Page<HcaInfoVO> pageList = new Page<HcaInfoVO>();
        for (HcaInfo hcaInfo : hcaInfoList) {
            HcaInfoVO hcaInfoVO = new HcaInfoVO();
            hcaInfoVO.forDomain(hcaInfo);
            pageList.add(hcaInfoVO);
        }
        BaseVOUtil.converterPage(hcaInfoList, pageList);
        return pageList;
    }
}
